@extends('layouts.master3')
@section('title')
{{"千里码-跬步"}}
@stop
@section('content')
  <div id="contain" class="contain" style="width:1070px;height:400px"></div>
@endsection

@section("js")
 <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
  <script>
$(function () {
<?php
use App\Utils;
$tot=0;
$pre=0;
foreach($ns as $k=>$n)
{
	if($n->rscore>0||$n['task']->id==44||$n['task']->id==80)$tot+=$n->rscore/100;
	else
   $tot+=$n['task']->score/100;
   $time=strtotime($n->created_at)*1000;
    if($time<0)$time=$pre;
    else $pre=$time+1;
    $ns[$k]['time']=$time;
    $ns[$k]['tot']=$tot;
}
?>
    var name="{{$user->name}}";
	var couts = {
<?php
foreach($ns as $n)
{
   echo $n['time'].": '".$n['task']->title."',\n";
}
?>
};

var ids = {
<?php
foreach($ns as $n)
{
   echo $n['time'].": '".Utils::id2url($n['task']->id)."',\n";
}
?>
};

	var Profit = {
<?php
foreach($ns as $n)
{
	if($n->rscore>0)
   echo $n['time'].":'".($n->rscore/100)."',\n";
	else
   echo $n['time'].":'".($n['task']->score/100)."',\n";
}
?>
};
    var indexs = null;
	$('#contain').highcharts({
		credits:{
			enabled:false // 禁用版权信息
		},
		title:{
			text:name+'的个人成长曲线图'
		},
		series: [{
			 showInLegend: false,
			name: '{{$user->name}}',
			marker: {
                    radius: 4
                },
			 data: [
<?php
foreach($ns as $k=>$n)
{
   echo '['.$n['time'].",".$n['tot']."],\n";
}
?>
            ]
		}],

		xAxis: {
			type: 'datetime',
				dateTimeLabelFormats: { // don't display the dummy year
					month: '%B'
				}
		},
		 yAxis: {
            title: {
                text: 'Source'
            },
			formatter:function(){
				return this.value+"分";
			},
            min: 0
        },
 plotOptions: {
                series: {
		   stickyTracking: true,
                    cursor: 'pointer',
			    marker: {
                        enabled: true,
			radius: 3,
                    }

			},
	      },
		tooltip: {
                        useHTML: true,
			formatter: function () {
				var s = "<a target=\"_blank\" href=\"/task/"+ids[this.x]+"\">" + couts[this.x] + "</a><br/>得分:" +Profit[this.x]+"</br>当前总分"+this.y+"</br>";
				return s;        
				//通过索引值展示数据                 
			},
			shared: true,
			 crosshairs: true
		},
		 legend: {
                align: 'left',
                verticalAlign: 'top',
                y: 20,
                floating: true,
                borderWidth: 0
            },
	});
});			
  </script>
@endsection
